package com.hjx.webdriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class Example  {
  public static void main(String[] args) {
    System.out.println(0);
    // Path to the ChromeDriver executable.
    System.setProperty("webdriver.chrome.driver", "D:/ws/cef_chromedriver/chromedriver1.exe");

    ChromeOptions options = new ChromeOptions();
    // Path to the CEF executable.
    options.setBinary("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
    // Port to communicate on. Required starting with ChromeDriver v2.41.
    options.addArguments("remote-debugging-port=12345");

    WebDriver driver = new ChromeDriver(options);
    driver.get("https://www.baidu.com");
    sleep(3000);  // Let the user actually see something!
    WebElement searchBox = driver.findElement(By.name("wd"));
    searchBox.sendKeys("ChromeDriver");
    System.out.println(1);
    searchBox.submit();
    System.out.println(2);
    sleep(30000);  // Let the user actually see something!

    driver.manage().getCookies().stream().forEach(cookie -> {
        System.out.println(cookie.getName() + cookie.isHttpOnly());
    });
    driver.quit();
  }

  static void sleep(int time) {
      try { Thread.sleep(time); } catch (InterruptedException e) {}
  }
}